package xyz.lovegu.server.bus.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.lovegu.server.bus.service.LeaveService;
import xyz.lovegu.server.bus.vos.LeaveVo;
import xyz.lovegu.server.sys.common.ResultMessage;
import xyz.lovegu.server.sys.common.ResultObj;
import xyz.lovegu.server.sys.common.ResultUtil;

/**
 * @author 老顾
 * @title: LeaveController
 * @projectName campus-prevention-system
 * @email: 1437594522@qq.com
 * @date 2022/5/10 17:35
 */
@Validated
@RestController
@RequestMapping("bus/leave")
@RequiredArgsConstructor
public class LeaveController {

    private final LeaveService leaveService;

    @PostMapping("addLeave")
    public ResultMessage<ResultObj> addLeave(@RequestBody LeaveVo leaveVo) {
        return ResultUtil.data(leaveService.addLeave(leaveVo));
    }

    @PostMapping("deleteBatchLeave")
    public ResultMessage<ResultObj> deleteBatchLeave(@RequestBody LeaveVo leaveVo) {
        return ResultUtil.data(leaveService.deleteBatchLeave(leaveVo));
    }

    @PostMapping("updateLeaveStatus")
    public ResultMessage<ResultObj> updateLeaveStatus(@RequestBody LeaveVo leaveVo) {
        return ResultUtil.data(leaveService.updateLeaveStatus(leaveVo));
    }

    @GetMapping("getLeaveByClasses")
    public ResultMessage<Object> getLeaveByClasses(LeaveVo leaveVo) {
        return ResultUtil.data(leaveService.getLeaveByClasses(leaveVo));
    }
}
